package com.kady.Dao.impl;

import com.kady.Dao.AdminDao;
import com.kady.entity.User;

import java.sql.SQLException;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: kady
 * \* Date: 2021/3/23
 * \* Time: 17:15
 * \* 千峰JAVA2101班
 * \* Description: 登录控制
 * \
 */

public class AdminImpl extends BaseDao implements AdminDao {
    /**
     * 查询用户
     */
    @Override
    public User selectUser(String username) throws SQLException {
        User person = selectOne(User.class,"select * from t_user where username = ?",username);
        return person;
    }

    /**
     * 用户注册
     */
    @Override
    public long register(Object... objs) throws SQLException {
        long res = update("INSERT INTO t_user (username,password,nick_name,gender,phone,email,user_create_time,is_vip,is_admin) VALUES (?,?,?,?,?,?,?,?,?)",objs);
        return res;
    }

    /**
     * 使用ID查询用户
     */
    @Override
    public User selectUserById(long userId) throws SQLException {
        User person = selectOne(User.class,"select * from t_user where user_id = ?",userId);
        return person;
    }
}
